import 'package:flutter/material.dart';
import 'package:flutter_base_plugin/flutter_base_plugin.dart';
import 'package:flutter_base_plugin_example/page/login/login_page.dart';
import 'package:flutter_base_plugin_example/page/mine/vm/mine_view_model.dart';
import '../../app_manager/app_router_manager.dart';
import '../../app_manager/app_routers.dart';
import '../../config/k_color.dart';
import '../../utils/common_utils.dart';

Widget MineHead(BuildContext context) {
  MineViewModel model = context.watch<MineViewModel>();
  // TODO: implement build
  return Container(
    height: 340.h,
    color: KColors.appBarColor,
    // width: getScreenWidth(),
    child: Stack(
      children: [
        Positioned(
          left: 0,
          right: 0,
          top: 0,
          bottom: 0,
          child: Image.asset(
            CommonUtils.getImgPath("user_bg", format: "jpg"),
            fit: BoxFit.cover,
          ),
        ),
        Positioned(
          left: 0,
          right: 0,
          top: 70,
          bottom: 0,
          child: Row(
            children: [
              Container(
                margin: EdgeInsets.only(left: 30.w),
                child: ClipOval(
                  child: Image.asset(
                    CommonUtils.getImgPath("user"),
                    fit: BoxFit.cover,
                    width: 120.w,
                    height: 120.w,
                  ),
                ),
              ),
              SizedBox(width: 20.w),
              _buildLogin(context, model),
            ],
          ),
        )
      ],
    ),
  );
}

Widget _buildLogin(BuildContext context, MineViewModel model) {
  if (!model.isLogin) {
    return InkWell(
      onTap: () {
        AppRoutesManager.navigateTo(context, AppRouters.login);
        // Navigator.of(context).push(MaterialPageRoute(
        //   builder: (context) => LoginPage(),
        // ));
      },
      child: const Text(
        "登陆/注册",
        style: TextStyle(
          color: KColors.white,
        ),
      ),
    );
  }

  return Column(
    mainAxisAlignment: MainAxisAlignment.center,
    crossAxisAlignment: CrossAxisAlignment.start,
    children: [
      Text(
        "",
        style: TextStyle(
          color: KColors.white,
          fontSize: 38.sp,
        ),
      ),
      Text(
        "普通会员",
        style: TextStyle(
          color: KColors.white,
        ),
      ),
    ],
  );
}
